package com.getpebble.android.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.getpebble.android.R;

public class LanguagePackView extends LinearLayout {
    private ImageView mCheckBoxView;
    boolean mIsInstalled = false;
    private TextView mLocalizedLanguageNameView;

    public LanguagePackView(Context context) {
        super(context);
        View rootView = LayoutInflater.from(context).inflate(R.layout.view_language_pack, this, true);
        this.mLocalizedLanguageNameView = (TextView) findViewById(R.id.language_name);
        this.mCheckBoxView = (ImageView) findViewById(R.id.language_checkmark);
    }

    public void setLanguageName(String languageName) {
        this.mLocalizedLanguageNameView.setText(languageName);
    }

    public void setInstalled(boolean isInstalled) {
        if (this.mIsInstalled != isInstalled) {
            int drawableId;
            if (isInstalled) {
                drawableId = R.drawable.checked;
            } else {
                drawableId = R.drawable.unchecked;
            }
            this.mCheckBoxView.setImageDrawable(getResources().getDrawable(drawableId));
            this.mIsInstalled = isInstalled;
        }
    }
}
